import { defineComponent as k, ref as m, reactive as w, onMounted as x, watch as V, openBlock as y, createBlock as B, Teleport as Y, createElementVNode as b, normalizeStyle as O, withModifiers as P, renderSlot as z, provide as g, createElementBlock as C, withCtx as I, createCommentVNode as $, inject as _, onBeforeUnmount as W, unref as v, normalizeClass as M, toDisplayString as N } from "vue";
const T = /* @__PURE__ */ k({
  __name: "YzPopper",
  props: {
    el: {}
  },
  emits: ["click", "beforetoggle"],
  setup(r, { expose: p, emit: l }) {
    const n = r, a = m(null), e = w({ left: 0, top: 0, width: 0, display: "none" }), t = l;
    x(() => {
      n.el && V(
        () => n.el.offsetWidth,
        () => s()
      );
    });
    function s() {
      e.left = n.el.offsetLeft, e.top = n.el.offsetTop + n.el.offsetHeight, e.width = n.el.offsetWidth;
    }
    function f() {
      s(), e.display = "block", setTimeout(() => {
        var u;
        return (u = a.value) == null ? void 0 : u.showPopover();
      }, 10);
    }
    function d() {
      var u;
      a.value.ontransitionend = () => {
        e.display = "none", a.value.ontransitionend = null;
      }, (u = a.value) == null || u.hidePopover();
    }
    return p({ open: f, close: d }), (u, i) => (y(), B(Y, { to: "body" }, [
      b("div", {
        ref_key: "oPopper",
        ref: a,
        class: "yz-popper",
        popover: "auto",
        style: O({ display: e.display, left: e.left + "px", top: e.top + "px", width: e.width + "px" }),
        onClick: i[0] || (i[0] = P((o) => t("click"), ["stop"])),
        onBeforetoggle: i[1] || (i[1] = (o) => t("beforetoggle", o))
      }, [
        z(u.$slots, "default", {}, void 0, !0)
      ], 36)
    ]));
  }
}), S = (r, p) => {
  const l = r.__vccOpts || r;
  for (const [n, a] of p)
    l[n] = a;
  return l;
}, j = /* @__PURE__ */ S(T, [["__scopeId", "data-v-b235e11a"]]), H = ["readonly", "autocomplete", "placeholder", "value"], D = { class: "yz-select-menu" }, E = /* @__PURE__ */ k({
  __name: "YzSelect",
  props: {
    modelValue: { type: [String, Number, Boolean, Object] },
    filterable: { type: Boolean, default: !1 },
    placeholder: { default: "请选择" },
    multiple: { type: Boolean, default: !1 }
  },
  emits: ["update:model-value"],
  setup(r, { emit: p }) {
    const l = r, n = w([]), a = m(null), e = m(null), t = m(null), s = m(null), f = p, d = () => {
      t.value.focus(), s.value = t.value.value, a.value.open();
    }, u = (i) => {
      f("update:model-value", i), s.value = null, a.value.close();
    };
    return g("props", l), g("options", n), g("inputValue", s), g("selectOption", u), (i, o) => {
      var h;
      return y(), C("div", {
        ref_key: "oControlSelect",
        ref: e,
        class: "yz-select"
      }, [
        b("input", {
          ref_key: "oInput",
          ref: t,
          type: "text",
          readonly: !l.filterable,
          autocomplete: l.filterable ? "on" : "off",
          placeholder: l.placeholder,
          value: s.value === null ? (((h = n.find((c) => c.value === l.modelValue)) == null ? void 0 : h.label) || l.modelValue).toString() : s.value,
          onClick: o[0] || (o[0] = (c) => d()),
          onInput: o[1] || (o[1] = (c) => s.value = c.target.value)
        }, null, 40, H),
        e.value ? (y(), B(j, {
          key: 0,
          ref_key: "oPopper",
          ref: a,
          el: e.value,
          onClick: o[2] || (o[2] = (c) => d()),
          onBeforetoggle: o[3] || (o[3] = (c) => c.newState == "closed" && (s.value = null))
        }, {
          default: I(() => [
            b("menu", D, [
              z(i.$slots, "default", {}, void 0, !0)
            ])
          ]),
          _: 3
        }, 8, ["el"])) : $("", !0)
      ], 512);
    };
  }
}), J = /* @__PURE__ */ S(E, [["__scopeId", "data-v-41e385d6"]]), L = ["disabled"], R = /* @__PURE__ */ k({
  __name: "YzOption",
  props: {
    label: {},
    value: { type: [String, Number, Boolean, Object] },
    disabled: { type: Boolean, default: !1 }
  },
  setup(r) {
    const p = _("props"), l = _("options"), n = _("inputValue"), a = _("selectOption"), e = r;
    t(), W(() => {
      l == null || l.splice(
        l == null ? void 0 : l.findIndex((s) => s === e),
        1
      );
    });
    function t() {
      l == null || l.push(e);
    }
    return (s, f) => {
      var d, u;
      return !((d = v(p)) != null && d.filterable) || v(n) !== null && (v(n) === "" || e.label.toString().includes(v(n).toString()) || e.value.toString().includes(v(n).toString())) ? (y(), C("button", {
        key: 0,
        class: M({ "yz-option": !0, active: ((u = v(p)) == null ? void 0 : u.modelValue) === e.value }),
        disabled: e.disabled,
        onClick: f[0] || (f[0] = P((i) => {
          var o;
          return (o = v(a)) == null ? void 0 : o(e.value);
        }, ["stop"]))
      }, [
        z(s.$slots, "default", {}, () => [
          b("span", null, N(e.label), 1)
        ], !0)
      ], 10, L)) : $("", !0);
    };
  }
}), q = /* @__PURE__ */ S(R, [["__scopeId", "data-v-296d17ca"]]), U = /* @__PURE__ */ k({
  __name: "YzSignature",
  props: {
    lineWidth: { type: Number, default: 5 },
    strokeStyle: { type: String },
    type: { type: String, default: "image/png" }
  },
  emits: ["start", "signing", "end"],
  setup(r, { expose: p, emit: l }) {
    const n = r, a = l;
    p({ clear: i });
    const e = m(null);
    let t = null, s = !1;
    x(() => {
      e.value && (e.value.width = e.value.offsetWidth, e.value.height = e.value.offsetHeight, t = e.value.getContext("2d"));
    });
    const f = (o) => {
      t && (s = !0, t.save(), t.lineWidth = n.lineWidth, t.lineCap = "round", t.lineJoin = "round", n.strokeStyle && (t.strokeStyle = n.strokeStyle), t.beginPath(), t.moveTo(o.offsetX, o.offsetY), a("start", { event: o }));
    }, d = (o) => {
      t && s && (t.lineTo(o.offsetX, o.offsetY), t.stroke(), a("signing", { event: o }));
    }, u = (o) => {
      t && e.value && (t.restore(), s = !1, a("end", { data: e.value.toDataURL(n.type), event: o }));
    };
    function i() {
      t && e.value && t.clearRect(0, 0, e.value.offsetWidth, e.value.offsetHeight);
    }
    return (o, h) => (y(), C("canvas", {
      ref_key: "oCanvas",
      ref: e,
      class: "yz-signature",
      onMousedown: f,
      onMousemove: d,
      onMouseup: u
    }, null, 544));
  }
}), A = /* @__PURE__ */ S(U, [["__scopeId", "data-v-3773aab2"]]);
export {
  q as YzOption,
  j as YzPopper,
  J as YzSelect,
  A as YzSignature
};
